package com.in.mobilerechargedth.adapter;

import java.util.List;

import com.in.mobilerechargedth.R;
import com.in.mobilerechargedth.model.TransponderModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SixthTransponderDetailScreenListViewAdapter extends BaseAdapter {

    List<TransponderModel> details;
    private LayoutInflater mInflater;

    public SixthTransponderDetailScreenListViewAdapter(List<TransponderModel> details,
            Context context) {
        super();
        this.details = details;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return details.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return details.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int arg0, View v, ViewGroup arg2) {
        // TODO Auto-generated method stub
        ViewHolder viewHolder = null;
        TransponderModel detail = details.get(arg0);

        if (v == null) {
            v = mInflater.inflate(R.layout.adapter_item_sixth_transponder_detail_screen, null);
            viewHolder = new ViewHolder();
            viewHolder.txtSatellite = (TextView) v.findViewById(R.id.txtSatellite);
            viewHolder.txtFrequencyName = (TextView) v.findViewById(R.id.txtFrequencyName);
            viewHolder.txtPolaraizationName = (TextView) v.findViewById(R.id.txtPolaraizationName);
            viewHolder.txtfecName = (TextView) v.findViewById(R.id.txtfecName);
            viewHolder.txtModulationName = (TextView) v.findViewById(R.id.txtModulationName);
            viewHolder.txtSymbolRate = (TextView) v.findViewById(R.id.txtSymbolRate);

            v.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) v.getTag();
        }

        viewHolder.txtSatellite.setText(detail.getSatellite());

        viewHolder.txtFrequencyName.setText(detail.getFrequency());
        viewHolder.txtPolaraizationName.setText(detail.getPolaraization());
        viewHolder.txtfecName.setText(detail.getFec());
        viewHolder.txtModulationName.setText(detail.getModulationDetail());
        viewHolder.txtSymbolRate.setText(detail.getSymbolRate());

        return v;
    }

    private class ViewHolder {
        TextView txtSatellite;
        TextView txtFrequencyName;
        TextView txtPolaraizationName;
        TextView txtfecName;
        TextView txtModulationName;
        TextView txtSymbolRate;
    }
}
